package mx.mvc.util;

import java.lang.reflect.Field;

import javax.servlet.http.HttpServletRequest;

import mx.mvc.model.ABean;

@SuppressWarnings("rawtypes")
public class RIBeanUtil {
	public static ABean getBean(HttpServletRequest request){
		ABean ob=null;
		String beanName=request.getParameter("className");
		try {
			Class cls=Class.forName(beanName);
			ob=(ABean) cls.newInstance();
			Field[] fs=cls.getDeclaredFields();
			for(Field f:fs){
				f.setAccessible(true);
				f.set(ob, request.getParameter(f.getName()));
				f.setAccessible(false);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} 
		return ob;
	}
}
